home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1998 February
/
Macworld (1998-02).dmg
/
Inside Macworld
/
Alphamania 2 & Effector Sets
/
AlphaMania 2
/
Set FX.dir
/
00101_Script_Compass Object
< prev
next >
Wrap
Text File
|
1997-12-19
|
4KB
|
143 lines
property pCompassSprite, pArrowsSprite, pTextSprite, pTextField, pCurVal, pCallBackObj, pRefcon
property pRange, pMin, pMax, pCenterPoint, pActive
on new me, propList
--pCompassSprite0, pArrowsSprite0, pTextSprite0, pTextField0, pCenterPoint0, pCurVal0, pCallBackObj0, pRefCon0
set pCompassSprite = getAProp(proplist,#lineSprite)
set pArrowsSprite = getAProp(proplist,#arrowsSprite)
set pTextSprite = getAProp(proplist,#textSprite)
set pTextField = getAProp(proplist,#textField)
set pCenterPoint = getAProp(proplist,#center)
set pMin = -720
set pMax = 720
set pCurVal = getAProp(proplist,#cur)
set pRange = pMax-pMin
set pActive = getAProp(proplist,#active)
set pCallBackObj = getAProp(proplist,#callback)
set pRefCon = getAProp(proplist,#ref)
setVal(me,pCurVal)
setEnabled(me,pActive)
return(me)
end
on wait me, waitTime
put the ticks into t
repeat while the ticks < t+waitTime
end repeat
end
on Click me
if not pActive then exit
repeat while the stillDown
put the mouseH - the locH of sprite the clickOn into x
put the mouseV - the locV of sprite the clickOn into y
if x = 0 then put -.0001 into x
put atan(float(y)/x)+0.5*pi() into a
if x < 1 then put a+pi() into a
put integer((a/(2*pi()))*360) into a
if a > 180 then put a-360 into a
setVal(me,a)
if objectP(pCallBackObj) then compassChange(pCallBackObj, pRefcon, a)
updateStage
end repeat
if objectP(pCallBackObj) then EndChange(pCallBackObj)
end
on Arrows me
if not pActive then exit
put the locH of the clickLoc into h1
put the locH of sprite the clickOn into h2
if h1 < h2 then
put "left" into side
put -1 into d
else
put "right" into side
put 1 into d
end if
set the member of sprite pArrowsSprite = member ("horizArrows"&&side)
set newVal = max(min(pCurVal+d,pMax),pMin)
if objectP(pCallBackObj) then compassChange(pCallBackObj, pRefcon, newVal)
updateStage
wait(me,5)
repeat while the stillDown
if rollover(pArrowsSprite) then
set the member of sprite pArrowsSprite = member ("horizArrows"&&side)
set pCurVal = max(min(pCurVal+d,pMax),pMin)
else
set the member of sprite pArrowsSprite = member "horizArrows"
end if
setVal(me,pCurVal)
if objectP(pCallBackObj) then compassChange(pCallBackObj, pRefcon, newVal)
wait(me,5)
end repeat
set the member of sprite pArrowsSprite = member "horizArrows"
if objectP(pCallBackObj) then EndChange(pCallBackObj)
end
on TextOut me
if the platform contains "Mac" then put numtochar(161) into degreeSymbol
else put numtochar(186) into degreeSymbol
if voidP(pCurVal) then put " " into field pTextField
else put string(integer(pCurVal))°reeSymbol into field pTextField
end
on SetVal me, newVal
puppetSprite pThumbSprite, TRUE
set pCurVal = newVal
drawLine(me)
TextOut(me)
--updateStage
end
on drawLine me
puppetSprite pCompassSprite, TRUE
put (float(pCurVal)/360)*2*pi()-0.5*pi() into a
put integer(cos(a)*14) into x
put integer(sin(a)*14) into y
if x = 1 or x = 0 then
put 2 into x
else if x = -1 then
put -2 into x
else if y = 1 or y = 0 then
put 2 into y
else if y = -1 then
put -2 into y
end if
put rect(pCenterPoint,pCenterPoint+point(x,y)) into r
if ((x < 0) and (y > 0)) or ((x > 0) and (y < 0)) then
set the castNum of sprite pCompassSprite = the number of cast "line2"
else
set the castNum of sprite pCompassSprite = the number of cast "line1"
end if
set the rect of sprite pCompassSprite = r
--updateStage
end
on SetEnabled me, enabled
set pActive = enabled
enableInterfaceElement(pCompassSprite,enabled)
enableInterfaceElement(pArrowsSprite,enabled)
enableInterfaceElement(pTextSprite,enabled)
end
on Release me
-- release all puppets, constraints, etc.
end